package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.ProfileTO;
import com.ecable.bean.StateTO;
import com.ecable.daoImpl.ProfileDAO;
import com.ecable.delegate.StateMgrDelegate;
import com.ecable.exception.ConnectionException;
import com.ecable.exception.DataNotFoundException;
import com.ecable.util.UtilConstants;

public class ViewRequestedOperatorsAction extends HttpServlet {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

               
		String path="";
		
		String usertype=request.getParameter("usertype");
			
		System.out.println("usertype"+usertype);
		Vector<ProfileTO> opv=null;
		
		try{
			 
				 opv=new ProfileDAO().getViewRequestedOperater(usertype);
			
			
			if(!opv.isEmpty()){
				
				request.setAttribute("status", UtilConstants._OPERATOR_INFO_REQUESTED);
				request.setAttribute("usertype", usertype);
				request.setAttribute("opinfo", opv);
				
				path=UtilConstants._VIEW_REQUEST__OPERATORS;
		
			}
			else
			{
				request.setAttribute("usertype", usertype);
				request.setAttribute("status", UtilConstants._NO__OPERATOR);
				path=UtilConstants._VIEW_REQUEST__OPERATORS;
				
			}
			
		}
		catch (Exception e) {
			
			request.setAttribute("status", UtilConstants._NO__OPERATOR);
			path=UtilConstants._VIEW_REQUEST__OPERATORS;
			
		}
		RequestDispatcher rd=request.getRequestDispatcher(path);
		
		rd.forward(request, response);
		
   }

}
